//
//  WKCollectionCell.m
//  WeKeTang
//
//  Created by ichina on 2017/9/25.
//  Copyright © 2017年 Dezhi Tiancheng Education Technology (Beijing) Co. Ltd. All rights reserved.
//

#import "WKCollectionCell.h"
#import <UIImageView+WebCache.h>

@interface WKCollectionCell ()

@property (nonatomic, strong) UIImageView *iconImageView;

@property (nonatomic, strong) YYLabel *titleLabel;

@end

@implementation WKCollectionCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self setupUI];
    }
    return self;
}
- (void)setupUI{
    
    self.iconImageView = [[UIImageView alloc]init];
    self.iconImageView.image = [UIImage imageNamed:@"banner1"];
    [self.contentView addSubview:self.iconImageView];
    
    self.titleLabel = [[YYLabel alloc]init];
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.text = @"整套课程";
    self.titleLabel.font = [UIFont systemFontOfSize:13];
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.textColor = [UIColor blackColor];
}
- (void)setModel:(WKCollectionModel *)model{
    
    _model = model;
    NSLog(@"单个图片地址：%@",[NSString stringWithFormat:@"http://www.dezhi.com%@",model.section_imgurl]);
//    NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.dezhi.com%@",model.section_imgurl]]];
//    UIImage *image = [UIImage imageWithData:data];
    [self.iconImageView setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kTestMainUrl,model.section_imgurl]] options:YYWebImageOptionShowNetworkActivity];
    self.titleLabel.text = model.section_name;
}
- (void)layoutSubviews{
    
    [super layoutSubviews];
    self.iconImageView.frame =CGRectMake(10, 15, 140, 120-30);
    
    self.titleLabel.frame =CGRectMake(CGRectGetMaxX(self.iconImageView.frame)+10, 5, kDeviceScreenWidth-20-140-10, 42);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
}

@end
